# @Time : 2024/7/21 15:44
# @Author : Adam
# @Version : v1.0
# @IDE : PyCharm
# @Project : tracer
import hashlib
import os
import sys
import uuid

import django
from django.conf import settings

base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(base_dir)
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tracer.settings')
django.setup()  # os.environ['DJANGO_SETTINGS_MODULE']


def md5(string):
    """MD5加密"""
    hash_obj = hashlib.md5(settings.SECRET_KEY.encode('utf-8'))
    hash_obj.update(string.encode('utf-8'))
    return hash_obj.hexdigest()


def uid(string):
    data = "{}-{}".format(str(uuid.uuid4()), string)
    return md5(data)


if __name__ == '__main__':
    m = md5('123456')
    print(m)
